// 1-cnpm install express socket.io
// 2- 创建支持socket的服务
const http = require("http");
const express = require("express");
const socketIo = require("socket.io");
const app = express();
const httpServer = http.createServer(app);
const io = socketIo(httpServer);// 支持socket
io.on("connection",function(socket){
	console.log("接收到前端的连接请求",socket.id);
	socket.on("one",function(a,b,c,d){
		console.log(a,b,c,d);
		io.emit("two",10,20,30,40)// 向客户端推送消息
	});
	socket.on("disconnect",function(){
		console.log("断开连接时执行",socket.id);
	})
})
app.use(express.static(__dirname));
httpServer.listen(80,function(){
	console.log('success');
})
